# -*- coding: utf-8 -*-
"""
Configuration file for the Dragonfly Aerodynamics Simulation.

This file contains all the necessary parameters to set up and run the simulation.
Values are based on the descriptions in the project's 'report.tex'.
"""

import numpy as np

# --- Geometry and Wing Kinematics ---
# Based on "Flapping wing design for a dragonfly-like micro air vehicle"
# and the idealized geometry approach in the report.
WING_SPAN = 0.07  # meters (7 cm)
WING_ROOT_CHORD = 0.04  # meters (4 cm)

# Kinematic parameters to define the wing's motion.
# The motion is typically a combination of sinusoidal functions.
FLAPPING_FREQUENCY = 40.0  # Hz
FLAPPING_AMPLITUDE = np.deg2rad(55)  # Peak-to-peak amplitude in radians
PITCHING_AMPLITUDE = np.deg2rad(40)  # Pitching motion amplitude in radians
DEVIATION_AMPLITUDE = np.deg2rad(10) # Deviation motion amplitude in radians

# Phase lags between motions (in radians)
# Pitching relative to flapping
PITCHING_PHASE_LAG = np.deg2rad(90)
# Deviation relative to flapping
DEVIATION_PHASE_LAG = np.deg2rad(0)


# --- Fluid and Flow Properties ---
AIR_DENSITY = 1.225  # kg/m^3
AIR_DYNAMIC_VISCOSITY = 1.81e-5  # Pa·s or kg/(m·s)
INLET_VELOCITY = 1.0  # m/s, for forward flight simulations


# --- Simulation Control ---
SIMULATION_TIME = 0.5  # Total simulation time in seconds
# Time step size. Report suggests 120-160 steps per flapping cycle.
# (1 / FLAPPING_FREQUENCY) / 160
TIME_STEP_SIZE = (1.0 / FLAPPING_FREQUENCY) / 160


# --- Numerical Scheme Settings ---
# As per the 'Numerical Scheme' section of the report.
SOLVER_TYPE = 'pressure-based-coupled'

# Spatial Discretization
# 'QUICK', 'UPWIND', 'CENTRAL_DIFFERENCING'
MOMENTUM_DISCRETIZATION = 'QUICK'
GRADIENT_EVALUATION = 'Green-Gauss-Node-Based'

# Temporal Discretization
TEMPORAL_DISCRETIZATION = 'First-Order-Implicit'

# Solver Convergence
# Inner loop iterations per time step
INNER_ITERATIONS = 50
# Residual thresholds
PRESSURE_RESIDUAL = 1e-4
VELOCITY_RESIDUAL = 1e-7


# --- Dynamic Meshing Parameters ---
# As per the 'Handling Wing Motion' section of the report.
# Spring-based smoothing settings
SPRING_CONSTANT = 0.001
# Local remeshing trigger
MAX_CELL_SKEWNESS = 0.85


# --- File I/O and Post-processing ---
# NOTE: You must generate this mesh file using an external tool (e.g., GMSH).
# This file should contain the hybrid mesh with named boundaries.
MESH_FILE = "mesh/dragonfly_hybrid_mesh.msh"

# Directory to save output files (e.g., VTK files for ParaView)
OUTPUT_DIR = "output/"

# Directory to save visualization images
VISUALIZATION_OUTPUT_DIR = "output/visualization/"

# Frequency of writing output files (e.g., write every 5 time steps)
OUTPUT_FREQUENCY = 5 